package com.liyuan.help_e.service.impl;

import com.liyuan.help_e.dao.TagDao;
import com.liyuan.help_e.model.Category;
import com.liyuan.help_e.model.Tags;
import com.liyuan.help_e.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class TagServiceImpl implements TagService {
    @Autowired
    TagDao tagDao;


    @Override
    public Map<String, Tags[]> getTags() {
        Map<String,Tags[]> map=new HashMap<>();
        Category[] categories = tagDao.selectCategories();
        for(Category category:categories){
            String name = category.getName();
            Tags[] tags = tagDao.selectTagsByName(category.getId());
            map.put(name,tags);
        }
        return map;
    }
}
